import Vue from 'vue'
import VueRouter from 'vue-router'
// import index from '../views/index.vue'

Vue.use(VueRouter)

const routes = [
  // {
  //   path: '*',
  //   redirect: '/menu'
  // },
  {
    path: '*',
    redirect: '/index'
  },
  {
    path: '/index',
    name: 'index',
    component: () => import("@/views/index.vue"),
    meta: {
      title: '首页'
    }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import("@/views/login.vue"),
    meta: {
      title: '登录'
    }
  },
  {
    path: '/menu',
    name: 'menu',
    redirect: "/laborunion-operation/operation",
    component: () => import("@/views/menu.vue"),
    // children: [{
    //   path: "/laborunion-operation/operation",
    //   name: "operation",
    //   component: () => import("@/views/laborunion-operation/operation.vue"),
    //   meta: {
    //     title: '公会经营'
    //   }
    // },],
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

const originalPush = VueRouter.prototype.push
// 修改 原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
